#!/usr/bin/env Python
# -*- coding:utf-8 -*-
# 51memo.1.py
# A memo demo 51备忘录
# author: De8uG


from color_me import ColorMe
__author__ = 'LuoXiang'

desc = '51备忘录'.center(30, '-')
print(desc)
welcome = 'welcome'
print(f'{welcome}', __author__)
print('请输入备忘信息：')

all_memo = []  
# 添加dict保存一条信息
"""
{
    'date': 1.1,
    'thing': 'python',
    'time': 30
}
{
    'time': 8,
    'thing': 'python',
}
"""


is_add = True
all_time = 0
while(is_add):  # 这是个循环输入
    in_date = input('日期(例2019.7.7):')
    year = in_date.split('.')[0]
    month = in_date.split('.')[1]
    day = in_date.split('.')[2]
    in_time = input('时间(例15:30):')
    hour = in_time.split(':')[0]
    minute = in_time.split(':')[1]
    in_thing = input('事件:')
    in_duration = input('时长(例01h30min)：')
    hours = in_duration[in_duration.find('h') - 2 : in_duration.find('h')]
    minutes = in_duration[in_duration.find('h') + 1 : in_duration.find('h') +3]
    print('待办列表'.center(30, '-'))
    # one = '{date}, 处理{thing}, 用时{time}'.format(date=in_date, thing=in_thing, time=in_time)
    time_dict = {'早晨' : [6, 7, 8], '上午' : [9, 10, 11], '中午' : [12, 13, 14], '下午' : [15, 16, 17], '傍晚' : [18, 19, 20], '晚上' : [21, 22, 23], '深夜' : [ 0, 1, 2], '凌晨' : [3, 4, 5] }
    date_color = ColorMe(f'{year}年{month}月{day}日').red()
    time_color = ColorMe(f'{hour}点{minute}分').green()
    thing_color = ColorMe(f'需要{in_thing}').blue()
    duration_color = ColorMe(f'{hours}小时{minutes}分').yellow()

    things_dict = {}
    things_dict['日期'] = date_color
    things_dict['时点'] = time_color
    things_dict['事件'] = thing_color
    things_dict['用时'] = duration_color

    all_memo.append(things_dict)
    all_time += int(hours) * 60 + int(minutes)
    num = 0
    for m in all_memo:
        num += 1
        print(f'{num}: {m}')

    print(f'共{len(all_memo)}条待办事项, 总时长：{all_time // 60}小时{all_time % 60}分。', end='')
    print('（y：继续添加，n: 退出）')
    is_add = input().strip() == 'y'